;; Comprehensive test for set! expressions

(display "=== Comprehensive set! Test ===")

;; Test 1: Basic variable modification
(define num 42)
(display "num = ")
(display num)

(set! num 100)
(display " after set! num 100: ")
(display num)

;; Test 2: String variable modification
(define greeting "Hello")
(display " greeting = ")
(display greeting)

(set! greeting "Goodbye")
(display " after set! greeting \"Goodbye\": ")
(display greeting)

;; Test 3: Variable reference in set!
(define source 25)
(define target 50)
(display " source = ")
(display source)
(display " target = ")
(display target)

(set! target source)
(display " after set! target source: target = ")
(display target)

;; Test 4: Arithmetic expression in set!
(define calculation 0)
(display " calculation = ")
(display calculation)

(set! calculation (+ 10 20 30))
(display " after set! calculation (+ 10 20 30): ")
(display calculation)

;; Test 5: Multiple sequential modifications
(define counter 1)
(display " counter = ")
(display counter)

(set! counter (+ counter 1))
(display " after increment: ")
(display counter)

(set! counter (* counter 3))
(display " after multiply by 3: ")
(display counter)

(set! counter (/ counter 2))
(display " after divide by 2: ")
(display counter)

;; Test 6: set! inside begin block
(define inside-begin 5)
(display " inside-begin = ")
(display inside-begin)

(begin
  (set! inside-begin 15)
  (display " inside begin, after set! 15: ")
  (display inside-begin)
  (set! inside-begin 25)
  (display " inside begin, after set! 25: ")
  (display inside-begin))

(display " outside begin, final value: ")
(display inside-begin)

;; Test 7: Complex expression with variables
(define x 2)
(define y 3)
(define result 0)
(display " x = ")
(display x)
(display " y = ")
(display y)
(display " result = ")
(display result)

(set! result (+ (* x x) (* y y)))
(display " after set! result (+ (* x x) (* y y)): ")
(display result)

;; Final summary
(display "=== Final Values ===")
(display "num: ")
(display num)
(display " greeting: ")
(display greeting)
(display " target: ")
(display target)
(display " calculation: ")
(display calculation)
(display " counter: ")
(display counter)
(display " inside-begin: ")
(display inside-begin)
(display " result: ")
(display result)